import unittest
from selenium import webdriver
from time import sleep
from Page.login import login_Page
from Page.rolemanagement import role
from selenium.webdriver.common.by import By
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.lp = login_Page(self.driver)
        self.lp.openurl('http://49.233.136.131:7009/roncoo-pay-web-boss/login')
        self.lp.login_success()
        self.js=role(self.driver)
        print('开始')

    def tearDown(self):
        sleep(5)
        self.driver.quit()
        print('结束')

    def test_01_tiaozhauntj(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.tianjia()
        sleep(3)
        dy1_loc = (By.XPATH, '/html/body/div[13]/div[1]/div/div/h1')
        dy1 = self.lp.find_element(dy1_loc).text
        self.assertIn("添加角色", dy1)


    def test_02_shanchu(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.sahnchu()
        sleep(2)
        self.js.quxiao()
        sleep(3)
        dy2_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[5]/div')
        dy2 = self.lp.find_element(dy2_loc).text
        self.assertIn("创建时间", dy2)

    def test_03_xiugai(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.xiugai()
        sleep(3)
        dy3_loc = (By.XPATH, '//*[@id="form"]/div[1]/p[1]/label')
        dy3 = self.lp.find_element(dy3_loc).text
        self.assertEqual("角色名称：", dy3)

    def test_04_fenpeicaidan(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.fenpei()
        sleep(3)
        dy4_loc = (By.XPATH, '//*[@id="form"]/div[1]/div[2]/div[1]/div/ul/li/a/span')
        dy4 = self.lp.find_element(dy4_loc).text
        self.assertEqual("关联了此角色的操作员：", dy4)


    def test_05_fenpeiquanxian(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.fenpeiquanxian()
        sleep(3)
        dy5_loc = (By.XPATH, '//*[@id="form"]/div[1]/div[2]/div[1]/div/ul/li/a/span')
        dy5 = self.lp.find_element(dy5_loc).text
        self.assertEqual("关联了此角色的操作员", dy5)

    def test_06_zuixiaohua(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.xiugai()
        sleep(3)
        self.js.zuixiao()
        sleep(2)
        dy6_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[2]/div')
        dy6 = self.lp.find_element(dy6_loc).text
        self.assertEqual("角色名称", dy6)

    def test_07_x(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.xiugai()
        sleep(3)
        self.js.cha()
        sleep(2)
        dy7_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[2]/div')
        dy7 = self.lp.find_element(dy7_loc).text
        self.assertEqual("角色名称", dy7)

    def test_08_xiugaineir(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.xiugai()
        sleep(2)
        self.js.xiugainr()
        sleep(3)
        self.js.baocc()
        sleep(2)
        dy8_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[2]/div')
        dy8 = self.lp.find_element(dy8_loc).text
        self.assertIn("角色名称", dy8)

    def test_09_tj(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.tianjia()
        sleep(2)
        self.js.mc()
        sleep(3)
        self.js.bm()
        sleep(2)
        self.js.miaoshu()
        sleep(2)
        self.js.baocc()
        dy9_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[2]/div')
        dy9 = self.lp.find_element(dy9_loc).text
        self.assertIn("角色名称", dy9)

    def test_10_tj(self):
        self.js.dianji()
        sleep(3)
        self.js.juese()
        sleep(3)
        self.js.sahnchu()
        sleep(2)
        self.js.queding()
        dy10_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[2]/div[2]/div[1]/div/table/thead/tr/th[2]/div')
        dy10 = self.lp.find_element(dy10_loc).text
        self.assertIn("角色名称", dy10)




if __name__ == '__main__':
    unittest.main()
